package domain

import (
	"github.com/hlhutu/gormplus"
	"ruoyi-go/internal/framework/db"
)

/**
 * 用户与岗位关联表 SysUserPost
 */
type SysUserPost struct {
	// 用户ID
	UserId int64 `json:"userId" gorm:"column:user_id" form:"userId"`

	// 岗位ID
	PostId int64 `json:"postId" gorm:"column:post_id" form:"postId"`
}

// TableName 映射数据库表名
func (m SysUserPost) TableName() string {
	return "sys_user_post"
}

// SysUserPost Model 定义
type sysUserPostModel struct {
	gormplus.Model[SysUserPost] // 使用泛型封装基础的 CRUD 操作
}

// SysUserPostModelInst 单例变量初始化
var sysUserPostModelInst *sysUserPostModel

// SysUserPostModel 获取 SysUserPost 单例模型
func SysUserPostModel() *sysUserPostModel {
	if sysUserPostModelInst == nil {
		// 将 SysUserPost 注册到 GORM DB，并初始化
		sysUserPostModelInst = &sysUserPostModel{Model: gormplus.NewModel(SysUserPost{}, db.GormDB)}
	}
	return sysUserPostModelInst
}
